package com.ly.juc.problem;


/**
 * @Classname Problem2
 * @Description
 * 写一个死锁
 * @Date 2020/11/18 15:27
 * @Author 冷心影翼
 */
public class Problem2 {

	public static void main(String[] args) {
		Object A = new Object();
		Object B = new Object();
		new Thread(()->{
			synchronized (A) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				synchronized (B) {

					System.out.println("getB");
				}
			}

		}).start();

		new Thread(()->{
			synchronized (B) {
				synchronized (A) {
					System.out.println("getA");
				}
			}
		}).start();
	}


}
